package com.java2nb.novel.mapper;

import static com.java2nb.novel.mapper.TestOneDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.java2nb.novel.entity.TestOne;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TestOneMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.14+08:00", comments="Source Table: test_one")
    BasicColumn[] selectList = BasicColumn.columnList(testId, testName);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.13+08:00", comments="Source Table: test_one")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.13+08:00", comments="Source Table: test_one")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.131+08:00", comments="Source Table: test_one")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TestOne> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.131+08:00", comments="Source Table: test_one")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TestOne> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.132+08:00", comments="Source Table: test_one")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TestOneResult")
    Optional<TestOne> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.132+08:00", comments="Source Table: test_one")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TestOneResult", value = {
        @Result(column="test_id", property="testId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="test_name", property="testName", jdbcType=JdbcType.VARCHAR)
    })
    List<TestOne> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.134+08:00", comments="Source Table: test_one")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.134+08:00", comments="Source Table: test_one")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, testOne, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.135+08:00", comments="Source Table: test_one")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, testOne, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.136+08:00", comments="Source Table: test_one")
    default int deleteByPrimaryKey(String testId_) {
        return delete(c -> 
            c.where(testId, isEqualTo(testId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.136+08:00", comments="Source Table: test_one")
    default int insert(TestOne record) {
        return MyBatis3Utils.insert(this::insert, record, testOne, c ->
            c.map(testId).toProperty("testId")
            .map(testName).toProperty("testName")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.138+08:00", comments="Source Table: test_one")
    default int insertMultiple(Collection<TestOne> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, testOne, c ->
            c.map(testId).toProperty("testId")
            .map(testName).toProperty("testName")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.139+08:00", comments="Source Table: test_one")
    default int insertSelective(TestOne record) {
        return MyBatis3Utils.insert(this::insert, record, testOne, c ->
            c.map(testId).toPropertyWhenPresent("testId", record::getTestId)
            .map(testName).toPropertyWhenPresent("testName", record::getTestName)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.141+08:00", comments="Source Table: test_one")
    default Optional<TestOne> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, testOne, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.141+08:00", comments="Source Table: test_one")
    default List<TestOne> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, testOne, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.142+08:00", comments="Source Table: test_one")
    default List<TestOne> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, testOne, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.142+08:00", comments="Source Table: test_one")
    default Optional<TestOne> selectByPrimaryKey(String testId_) {
        return selectOne(c ->
            c.where(testId, isEqualTo(testId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.143+08:00", comments="Source Table: test_one")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, testOne, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.143+08:00", comments="Source Table: test_one")
    static UpdateDSL<UpdateModel> updateAllColumns(TestOne record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(testId).equalTo(record::getTestId)
                .set(testName).equalTo(record::getTestName);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.144+08:00", comments="Source Table: test_one")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TestOne record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(testId).equalToWhenPresent(record::getTestId)
                .set(testName).equalToWhenPresent(record::getTestName);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.145+08:00", comments="Source Table: test_one")
    default int updateByPrimaryKey(TestOne record) {
        return update(c ->
            c.set(testName).equalTo(record::getTestName)
            .where(testId, isEqualTo(record::getTestId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-30T14:48:01.145+08:00", comments="Source Table: test_one")
    default int updateByPrimaryKeySelective(TestOne record) {
        return update(c ->
            c.set(testName).equalToWhenPresent(record::getTestName)
            .where(testId, isEqualTo(record::getTestId))
        );
    }
}